<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="html" />
	<xsl:include href="common.xsl" />
	<xsl:template match="/">
		<html>
			<head>
				<title><xsl:value-of select="/experiment_output/experiment/@name"/></title>
				<style type="text/css">
					body
					{
					background-color: #EEEEEE;
					}
					th 
					{
					background-color: #6633CC;
					color: #FFFFFF;
					}
					th a:link
					{
					color: #FFFFFF;
					}
					td.error
					{
					background-color: #FF3300;
					color: #FFFFFF;
					}
					.bio
					{
					color: #FF0000;
					}
					.nonbio
					{
					color: #0000FF;
					}
					table
					{
					width: 50%;
					}
					table.header
					{
					width: 50%;
					}
					table.key
					{
						width: 30%;
						margin-left: auto;
						margin-right: auto;
					}
					table.layout
					{
						width: 100%;
						vertical-align: top;
					}
				</style>
				<script type="text/javascript">
					function showhide(which)
					{
						if(!document.getElementById)
							return;

						if(which.style.display=="none")
						{
							which.style.display = 'block';
						}
						else
						{
							which.style.display = 'none';
						}
					}
				</script>
			</head>
			<body>
				NexradExplorer Experiment Results File: version <xsl:value-of select="/experiment_output/@version"/>
				<table class="header">
					<tr>
						<th>Date</th><th>Start Time</th><th>End Time</th>
					</tr>
					<tr>
						<td><xsl:value-of select="/experiment_output/date"/></td>
						<td><xsl:value-of select="/experiment_output/start_time"/></td>
						<td><xsl:value-of select="/experiment_output/end_time"/></td>
					</tr>
				</table>

				<hr width="100%" />
				<xsl:apply-templates select="/experiment_output/summary_statistics"/>
				<xsl:apply-templates select="/experiment_output/experiment"/>	
				<xsl:apply-templates select="/experiment_output/results"/>
				<hr width="100%" />
			</body>
		</html>
	</xsl:template>
	<xsl:template match="results">
		<h1>Experiment Results</h1>
		<xsl:for-each select="result">
			<h3>Group <xsl:value-of select="position()" /></h3>

			<xsl:apply-templates select="./training_files">
				<xsl:with-param name="index" select="position()" />
			</xsl:apply-templates>

			<br />

			<xsl:apply-templates select="./target_files" />

			<br />

			<xsl:if test="./expected_result">
			<table border="1">
				<tr><th>True Class</th><th>Predicted Class</th></tr>
				<tr>
					<xsl:choose>
						<xsl:when test="expected_result != actual_result">
							<td class="error"><xsl:value-of select="expected_result" /></td>
							<td class="error"><xsl:value-of select="actual_result" /></td>
						</xsl:when>
						<xsl:otherwise>
							<td><xsl:value-of select="expected_result" /></td>
							<td><xsl:value-of select="actual_result" /></td>
						</xsl:otherwise>
					</xsl:choose>
				</tr>
			</table>

			</xsl:if>
			<xsl:if test="./classification">
			<table border="1">
				<tr><th>Classification</th></tr>
				<tr><td><xsl:value-of select="classification" /></td></tr>
			</table>
			</xsl:if>

			<br />

			<xsl:apply-templates select="distribution" />

			<hr />
		</xsl:for-each>
	</xsl:template>

	<xsl:template match="distribution">
		<table width="20%" border="1">
			<tr><th colspan="2">Distribution</th></tr>
			<xsl:for-each select="class">
				<tr>
					<td>Class <xsl:value-of select="./@index" /></td>
					<td><xsl:value-of select="." /></td>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>

	<xsl:template match="summary_statistics">
		<h1>Summary</h1>
		<table border="1">
			<tr><th colspan="2">Statistics</th></tr>
			<tr><td>Number of Experiments</td><td><xsl:value-of select="count"/></td></tr>
			<!-- 
			<tr><td>Mean Confidence</td><td><xsl:value-of select="mean_confidence"/></td></tr>
			<tr><td>Confidence Standard Deviation</td><td><xsl:value-of select="std_dev_confidence"/></td></tr>
			<tr><td>Best Confidence</td><td><xsl:value-of select="best_confidence"/></td></tr>
			<tr><td>Worst Confidence</td><td><xsl:value-of select="worst_confidence"/></td></tr>
			-->
			<tr><td>Accuracy Over Set</td><td><xsl:value-of select="accuracy"/>%</td></tr>
		</table>
	</xsl:template>


</xsl:stylesheet>
